﻿using System.Windows;

namespace SHomeWorkshop.LunarPresentation.Commands
{
    public partial class Command
    {
        public static void BraceLocationSetup(Expressions.Brace.BraceLocation braceLocation)
        {
            if (Globals.selectedEditor == null) return;
            if (Globals.selectedEditor.SelectedExpression == null) return;

            LunarPresentation.Expressions.Expression curEx
                = Globals.selectedEditor.SelectedExpression;

            Expressions.Brace brace = curEx as Expressions.Brace;

            if (brace == null)
            {
                MessageBox.Show("只有括弧（不要与“括弧式”混淆）才支持“设置括弧位置”操作！", Globals.appName,
                    MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (brace.Braces == braceLocation) return;//本就是这种。

            ModifingItem mi = new ModifingItem();
            Action action = new Action(brace.ExID, -1, brace.GetType().Name, "Braces", brace.Braces.ToString(),
                braceLocation.ToString());

            brace.Braces = braceLocation;

            mi.Add(action);
            brace.Editor.Do(mi);
        }
    }
}
